<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'巡检签到'"
			:customBack="back"
		></u-navbar>
		<u-form :model="signForm" ref="signForm" label-width="100px" style="padding: 24rpx;">
			<!-- <u-form-item label="任务名称" >
				<u-input :border="border" :disabled="true" v-model="signForm.name"></u-input>
			</u-form-item> -->
			<u-form-item label="巡检状态" prop="feedbackStatusName">
				<u-input :border="border" type="select" :select-open="feedbackStatusShow" v-model="signForm.feedbackStatusName" placeholder="请选择当前状态" @click="feedbackStatusShow=true"></u-input>
			</u-form-item>
			<u-form-item label-position="left" label="巡检描述">
				<u-input type="textarea" :border="border" placeholder="请填写巡检描述" v-model="signForm.feedback" />
			</u-form-item>
		<!-- 	<u-form-item label-position="left" label="巡检图片">
				<u-image width="100%" height="300rpx" :src="signForm.signPic"></u-image>
			</u-form-item> -->
		</u-form>
		
		<u-button @click="submit" type="primary" style="margin: 24rpx;">提交</u-button>
		
		<u-select mode="single-column" :list="feedbackStatusList"  v-model="feedbackStatusShow" @confirm="feedbackStatusConfirm"></u-select>
	</view>
</template>

<script>
	import utils from "../../utils/utils.js"
	export default {
		data() {
			return {
				border:true,
				feedbackStatusShow:false,
				taskId:"",
				signForm:{
					name:'示例任务'
				},
				src:'',
				feedbackStatusList:[
					{
						label:'正常',
						value:0
					},
					{
						label:'异常',
						value:1
					}
				],
				rules:{
					feedbackStatusName: [
						// 对name字段进行必填验证
						{
							required: true,
							message: '请选择巡检状态',
							trigger: ['change','blur']
						},
					],
				}
			}
		},
		onReady() {
			this.$refs.signForm.setRules(this.rules);
		},
		onLoad(e) {
			this.taskId = e.taskId;
		},
		onShow() {
			this.signForm.taskId=this.taskId
			window.native.acceptUrl(res=>{
				if(res!=null){
					this.signForm.signPic = res
				}
			})
		},
		methods: {
			back(){
				window.native.back()
			},
			feedbackStatusConfirm(e){
				e.map((val, index) => {
					this.signForm.feedbackStatus = val.value
					this.signForm.feedbackStatusName = val.label
				})
			},
			submit(){
				this.$refs.signForm.validate(valid => {
					if (valid) {
						console.log(this.signForm)
						this.utils.request("/api/app/handle/addInspectionTaskSign", this.signForm, "post", "app", true).then(res => {
							console.log(`返回结果：`, res)
							this.back()
						}).catch(error => {
							console.log(error)
						})
					} else {
						console.log('验证失败');
					}
				});
			}
		}
	}
</script>

<style>

</style>
